<template>
    <h2>登录</h2>
    <table border="1">
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="name"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="pwd"/>
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" value="登录" @click="Login"/>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
    import {ref,onMounted} from 'vue';
    import axios from 'axios';
    import {useCounterStore} from '../stores/counter.ts';

    const Cstore=useCounterStore();

    const name=ref("");
    const pwd=ref("");

    const Login=()=>{
        axios.get("https://localhost:7010/api/Dept/LoginInfo",{
            params:{
                Uname:name.value,
                Upwd:pwd.value
            }
        })
        .then(res=>{
            if(res.data==null){
                alert('登录失败');
            }
            else{
                alert('登录成功');
                console.log(res.data);
                Cstore.Username=res.data.U_Name;
                console.log(Cstore.Username);
            }
        })
    }

</script>
